home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Clock / Sources / ClockSel.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  5.8 KB  |  211 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                ClockSel.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                Lonnie Millett
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef CLOCKSEL_H
  14. #include "ClockSel.h"
  15. #endif
  16.  
  17. #ifndef CLOCKPAR_H
  18. #include "ClockPar.h"
  19. #endif
  20.  
  21. // ----- Framework Includes -----
  22.  
  23. #ifndef FWMEMMGR_H
  24. #include <FWMemMgr.h>
  25. #endif
  26.  
  27. #ifndef FWPART_H
  28. #include "FWPart.h"
  29. #endif
  30.  
  31. // ----- OpenDoc Includes -----
  32.  
  33. #ifndef _SHAPE_
  34. #include <Shape.h>
  35. #endif
  36.  
  37. #ifndef _DRAGDROP_
  38. #include <DragDrop.h>
  39. #endif
  40.  
  41. #ifndef _XMPSESSN_
  42. #include <XMPSessM.h>
  43. #endif
  44.  
  45. #ifndef _STDPROPS_
  46. #include <StdProps.h>
  47. #endif
  48.  
  49. #ifndef _STDTYPES_
  50. #include <StdTypes.h>
  51. #endif
  52.  
  53. #ifndef _TRNSFORM_
  54. #include <Trnsform.h>
  55. #endif
  56.  
  57. #ifndef _STORAGEU_
  58. #include <StorageU.h>
  59. #endif
  60.  
  61. #ifndef _EXCEPT_
  62. #include <Except.h>
  63. #endif
  64.  
  65. #ifndef _TRANSLAT_
  66. #include <Translat.h>
  67. #endif
  68.  
  69. // ----- Macintosh Includes -----
  70.  
  71. #if defined(FW_BUILD_MAC) && !defined(__DRAG__)
  72. #include <Drag.h>
  73. #endif
  74.  
  75. #pragma segment ClockPart
  76.  
  77. //==============================================================================
  78. //    •• class CClockSelection
  79. //==============================================================================
  80.  
  81. //---------------------------------------------------------------------------------------
  82. //    • CClockSelection::CClockSelection
  83. //---------------------------------------------------------------------------------------
  84.  
  85. CClockSelection::CClockSelection()
  86. {
  87.     fClockPart = NULL;
  88. }
  89.  
  90. //---------------------------------------------------------------------------------------
  91. //    • CClockSelection::InitClockSelection
  92. //---------------------------------------------------------------------------------------
  93.  
  94. void CClockSelection::InitClockSelection(CClockPart* clockPart)
  95. {
  96.     InitSelection(clockPart, FALSE, FALSE);
  97.     
  98.     fClockPart = clockPart;
  99. }
  100.  
  101. //---------------------------------------------------------------------------------------
  102. //    • CClockSelection::~CClockSelection
  103. //---------------------------------------------------------------------------------------
  104.  
  105. CClockSelection::~CClockSelection()
  106. {    
  107. }
  108.  
  109. //---------------------------------------------------------------------------------------
  110. //    • CClockSelection::CloseSelection
  111. //---------------------------------------------------------------------------------------
  112.  
  113. void CClockSelection::CloseSelection()
  114. {
  115.     // Nothing to do here
  116. }
  117.  
  118. //---------------------------------------------------------------------------------------
  119. //    • CClockSelection::DoClear
  120. //---------------------------------------------------------------------------------------
  121.  
  122. FW_Boolean CClockSelection::DoClear()
  123. {
  124.     // Nothing to do here
  125.     return FALSE;
  126. }
  127.  
  128. //---------------------------------------------------------------------------------------
  129. //    • CClockSelection::SelectAll
  130. //---------------------------------------------------------------------------------------
  131.  
  132. void CClockSelection::SelectAll()
  133. {
  134.     // Nothing to do here
  135. }
  136.  
  137. //---------------------------------------------------------------------------------------
  138. //    • CClockSelection::IsEmpty
  139. //---------------------------------------------------------------------------------------
  140.  
  141. FW_Boolean CClockSelection::IsEmpty() const
  142. {
  143.     return TRUE;
  144. }
  145.  
  146. //---------------------------------------------------------------------------------------
  147. //    • CClockSelection::ExternalizeSelection
  148. //---------------------------------------------------------------------------------------
  149.  
  150. void CClockSelection::ExternalizeSelection(XMPStorageUnit* storageUnit, FW_CFrame* commandFrame, XMPCloneKind cloneKind)
  151. {
  152.     FW_UNUSED(storageUnit);
  153.     FW_UNUSED(commandFrame);
  154.     FW_UNUSED(cloneKind);
  155. }
  156.  
  157. //---------------------------------------------------------------------------------------
  158. //    • CClockSelection::InternalizeSelection
  159. //---------------------------------------------------------------------------------------
  160.  
  161. FW_Boolean CClockSelection::InternalizeSelection(XMPStorageUnit* storageUnit, XMPCloneKind cloneKind)
  162. {
  163.     FW_UNUSED(cloneKind);
  164.  
  165.     FW_Boolean internalized = FALSE;
  166.     
  167.     XMPTranslation *translate = GetPart()->GetSession()->GetTranslation();
  168.     XMPType PICTType = translate->GetISOTypeFromPlatformType('PICT', kXMPPlatformDataType);
  169.     XMPType sndType = translate->GetISOTypeFromPlatformType('snd ', kXMPPlatformDataType);
  170.  
  171.     if (storageUnit->Exists(kXMPPropContents, PICTType, 0))
  172.     {
  173.         storageUnit->Focus(kXMPPropContents, kXMPPosUndefined, PICTType, (XMPValueIndex)0, kXMPPosUndefined);
  174.                        
  175.         unsigned long pictSize = storageUnit->GetSize();
  176.         PicHandle pictHandle = (PicHandle)FW_CMemoryManager::AllocateSystemHandle(pictSize);
  177.         THROW_IF_NULL(pictHandle);
  178.         
  179.         FW_CMemoryManager::LockSystemHandle((FW_PlatformHandle)pictHandle);
  180.         storageUnit->GetValue(pictSize, (XMPValue)*pictHandle);
  181.         FW_CMemoryManager::UnlockSystemHandle((FW_PlatformHandle)pictHandle);
  182.         
  183.         fClockPart->SetBackgroundPICT(pictHandle);
  184.         
  185.         fClockPart->InvalidateAllFrames(fClockPart->GetDefaultPresentation(), NULL, NULL);
  186.  
  187.         internalized = TRUE;
  188.     }
  189.     // We should use kXMPApplesnd here but it is currently defined wrong
  190.     // Just type cast the string for right now
  191.     else if (storageUnit->Exists(kXMPPropContents, (XMPValueType)sndType, 0))
  192.     {
  193.         storageUnit->Focus(kXMPPropContents, kXMPPosUndefined, (XMPValueType)sndType, (XMPValueIndex)0, kXMPPosUndefined);
  194.                        
  195.         unsigned long sndSize = storageUnit->GetSize();
  196.         FW_PlatformHandle sndHandle = FW_CMemoryManager::AllocateSystemHandle(sndSize);
  197.         THROW_IF_NULL(sndHandle);
  198.         
  199.         FW_CMemoryManager::LockSystemHandle(sndHandle);
  200.         storageUnit->GetValue(sndSize, (XMPValue)*sndHandle);
  201.         FW_CMemoryManager::UnlockSystemHandle(sndHandle);
  202.         
  203.         fClockPart->SetChimeSound(sndHandle);
  204.  
  205.         internalized = TRUE;
  206.     }
  207.         
  208.     return internalized;
  209. }
  210.  
  211.